package com.pig4cloud.pig.village.welfare.controller;

import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.village.api.entity.Welfare;
import com.pig4cloud.pig.village.api.entity.WelfareResource;
import com.pig4cloud.pig.village.welfare.service.IWelfareResourceService;
import com.pig4cloud.pig.village.welfare.service.IWelfareService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author limbray.li
 * @date 2021/6/19
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/welfare-resource")
@Api(value = "welfare-resource", tags = "福利金额管理模块")
public class WelfareResourceController {
	@Resource
	private IWelfareResourceService welfareResourceService;

	@GetMapping("/list")
	public R<List<WelfareResource>> listAll() {
		return R.ok(welfareResourceService.list());
	}

	@GetMapping("/get")
	public R<WelfareResource> get(Long id) {
		return R.ok(welfareResourceService.getById(id));
	}

	@PutMapping("/deleteById")
	public R delete(Long id) {
		return R.ok(welfareResourceService.removeById(id));
	}

	@PostMapping("/add")
	public R add(@RequestBody WelfareResource welfare) {
		return R.ok(welfareResourceService.save(welfare));
	}
}
